<!-- 我的报名 -->
<template>
	<zh-app style="background-color: white;font-family: '阿里巴巴普惠体'">
		<!-- 导航栏 -->
		<zh-navbar title="我的报名" color="#85a5ff" linear="right" />
		<zh-spin :load="data.loading" tip="信息加载中，请耐心等候">
			<view v-if="data.showEnrollList.length<=0">
				<zh-result title="没有数据" subTitle="您还没有报名记录" :showBtn="true" btnText="前往报名" @click="gotoBM"></zh-result>
			</view>
			<!-- 主体 -->
			<view v-for="(item, index) in data.showEnrollList" :key="index">
				<zh-sheet 
					class="round-tl-6 round-tr-6 flex-center" 
					style="backgroundImage: linear-gradient(to right, #adc6ff, #2f54eb)"
					:padding="[20,20]"
					:margin="[32,24,32,10]"
					:height="50">
					<zh-text :fontSize="38" color="#ffffff" :label="item.year+'年报名'"></zh-text>
				</zh-sheet>
				<zh-card :round="0" :margin="[10, 0]" :padding="[24,0]" :shadow="0" v-for="(studentItem, indexStu) in item.enrollList" :key="'stu'+indexStu">
					<template v-slot:title>
						<view>
							<view style="border-left: 10rpx solid #2f54eb;" class="flex-row-center-start">
								<zh-text :fontSize="36" class="text-weight-b pl-10" :label="studentItem.childFullName"></zh-text>
								<zh-tag  :fontSize="26" size="s" :round="3" :label="studentItem.schoolCategory==='1'?'幼儿园':(studentItem.schoolCategory==='2'?'小学':'初中')"></zh-tag>
								<tm-icon :fontSize="42" :name="data.hiddenFlag?'tmicon-eye-slash':'tmicon-eye'" style="margin: 0 20rpx;" @tap="changeSensitive"></tm-icon>
							</view>
							<view class="pt-20 flex-row-center-start">
								<zh-text :fontSize="26" label="证件号码:"></zh-text>
								<zh-text :fontSize="26" :label="studentItem.childIdcard"></zh-text>
							</view>
						</view>
					</template>
					<template v-slot:content>
						<zh-sheet :margin="[0, 0, 0, 20]" :padding="[24,20]" :shadow="0" :round="3" style="backgroundImage: linear-gradient(to right, #ffffff, #D9D9D9);"
							v-for="(schoolItem, indexSch) in studentItem.enrollList" :key="'sch'+indexSch" text>
							<view class="flex-row-center-start" style="margin: 10rpx 0">
								<zh-text color="black" label="报名学校："></zh-text>
								<view class="flex-row-center-start">
									<zh-text :label="schoolItem.schoolName"></zh-text>
								</view>
							</view>
							<zh-sheet v-if="schoolItem.deployFlag==='1'" :margin="[0, 10]" :padding="[0,0]" :round="2"
								color="orange" text>
								<zh-text :label="schoolItem.basis"></zh-text>
							</zh-sheet>
							<view class="flex-row-center-start" style="margin: 10rpx 0">
								<zh-text color="black" label="报名编号："></zh-text>
								<zh-text :label="schoolItem.applyId"></zh-text>
								<zh-tag v-if="schoolItem.schoolCategory!=='1'&&schoolItem.aspirationType!=='1'" :fontSize="26" :followTheme="false"
									color="orange" size="s" :round="3" label="调剂志愿"></zh-tag>
							</view>
							<view class="flex-row-center-start" v-if="schoolItem.serialNum" style="margin: 10rpx 0">
								<zh-text color="black" label="摇号序号："></zh-text>
								<zh-text :label="schoolItem.serialNum"></zh-text>
							</view>
							<view v-if="schoolItem.schoolCategory==='1'" class="flex-row-center-start" style="margin: 10rpx 0">
								<zh-text color="black" label="报名学段："></zh-text>
								<zh-text :label="schoolItem.configTypeName"></zh-text>
							</view>
							<view v-if="schoolItem.configName" class="flex-row-center-start" style="margin: 10rpx 0">
								<zh-text color="black" label="报名类别："></zh-text>
								<zh-text :label="schoolItem.configName"></zh-text>
							</view>
							<view class="flex-row-center-start">
								<zh-text color="black" label="报名状态："></zh-text>
								<zh-tag :fontSize="26" :followTheme="false" :color="schoolItem.color" size="s" :round="2"
									:label="schoolItem.enrollStatus==='3'&&schoolItem.authStatus==='2'?'审核不通过':schoolItem.enrollStatusName"></zh-tag>
							</view>
							<zh-card v-if="schoolItem.tjStatus==='3'||schoolItem.tjStatus==='4'" :margin="[0,20]" :title="tjItem.tjType==='1'?'调剂第'+tjItem.aspirationType+'志愿':'学校调剂'" v-for="(tjItem, index) in schoolItem.tjList" :key="index">
								<template v-slot:content>
									<view  class="flex-row-center-start" >
										<zh-text color="black"  :label="tjItem.toSchoolName"></zh-text>
										<view :style="{width: tagWidth}" class="flex-row-center-end">
										<zh-tag :fontSize="26" :followTheme="false" 
										:color="tjItem.authStatus==='0'?'#FAAD14':(tjItem.authStatus==='1'?'#52C41A':'#EB2F96')" size="s" :round="3" :label="tjItem.authStatus==='0'?'待审核':(tjItem.authStatus==='1'?'录取':'不予录取')"></zh-tag>
										</view>
									</view>
								</template>
							</zh-card>
							<view class="flex flex-row" v-if="schoolItem.tjStatus==='2'">
								<view class="flex-1 mr-32" style="margin: 0 auto">
								<zh-button
									label="调剂申请"
									block
									color="#85a5ff"
									linear="right"
									@click="tjClick(schoolItem.studentEnrollId)"
								></zh-button>
								</view>
							</view>
							<zh-sheet color="red"
								v-if="studentItem.schoolCategory!=='1'&&schoolItem.enrollStatus==='0'&&schoolItem.authStatus==='0'"
								:margin="[0, 10]" :padding="[10,20]" :round="2" text>
								<zh-text :label="'学校审核时间参考'+item.year+'年东阳市义务教育阶段学校招生工作日程安排'"></zh-text>
							</zh-sheet>
						</zh-sheet>
						<!-- <zh-divider></zh-divider> -->
					</template>
					
				</zh-card>
				
			</view>
		</zh-spin>
		<zlb-footer></zlb-footer>
	</zh-app>
</template>
<script lang="ts" setup>
	import {
		ref,
		reactive
	} from "vue";
	import {
		onLoad,onShow
	} from "@dcloudio/uni-app";
	import {
		isElder
	} from '@/common/utils/util';
	// ------------------接收传入参数(组件)-------------------

	// ------------------变量区------------------------------
	// 主数据
	const data = reactive({
		loading: false,
		hiddenFlag: true,
		// 学生报名数组
		showEnrollList: [] as any,
	})
	const tagWidth = computed(() => {
	  return isElder() ? '300rpx' : '200rpx'
	});
	// ------------------方法区------------------------------
	// 跳转到报名列表
	const gotoBM = () => {
		$router.replace('/pages/edu/enroll/stageSelect',{})
	}
	const changeSensitive = () => {
		data.hiddenFlag = !data.hiddenFlag
		getEnrollInfo();
	}
	// 获取已报名数据
	const getEnrollInfo = () => {
		data.loading = true
		let params = {
			hiddenFlag: data.hiddenFlag
		}
		$api.common.send.post("eduStudentEnroll0008", params).then((res: any) => {
			data.showEnrollList = res.result||[]
			// 设置报名状态颜色
			for (let item of data.showEnrollList) {
				for (let item2 of item.enrollList) {
					for (let item3 of item2.enrollList) {
						switch (item3.enrollStatus){
							case '0':
								item3.color = '#FAAD14'
								break;
							case '1':
								item3.color = '#6E8DF5'
								break;
							case '2':
								item3.color = '#52C41A'
								break;
							case '3':
								item3.color = '#EB2F96'
								break;
							case '4':
								item3.color = '#BFBFBF'
								break;
							case '5':
								item3.color = '#BFBFBF'
								break;
							case '6':
								item3.color = '#EB2F96'
								break;
							default:
								break;
						}
					}
				}
			}
			data.loading = false
		}).catch(() => {
			data.loading = false
		})
	}
	const tjClick=(studentEnrollId:string)=>{
		if(studentEnrollId){
			$router.push('/pages/edu/tjApply/index',{studentEnrollId:studentEnrollId})
		}
		
	}
	// ------------------钩子函数----------------------------
	// 初始化
	onShow(() => {
		getEnrollInfo();
	})
</script>
<style lang="scss" scoped>

</style>
